export default [
    {
        name: "center",
        path: '/center',
        // 路由懒加载() => import("组件路径")
        component: () => import("@/pages/Center"),
        children: [
            {
                path: '/center/myorder',
                component: () => import("@/pages/Center/MyOrder")
            },
            {
                path: '/center/grouporder',
                component: () => import("@/pages/Center/GroupOrder")
            },
            {
                path: '/center',
                redirect: '/center/myorder'
            }
        ],
        meta: {
            show: true
        }
    },
    {
        name: "paysuccess",
        path: '/paysuccess',
        component: () => import('@/pages/PaySuccess'),
        meta: {
            show: true
        }
    },
    {
        name: "pay",
        path: '/pay',
        component: () => import('@/pages/Pay'),
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == '/trade') {
                next();
            } else {
                next(false);
            }
        },
        meta: {
            show: true
        }
    },
    {
        name: "trade",
        path: '/trade',
        component: () => import('@/pages/Trade'),
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == '/shopcart') {
                next();
            } else {
                next(false);
            }
        },
        meta: {
            show: true
        }
    },
    {
        name: "shopcart",
        path: '/shopcart',
        component: () => import('@/pages/ShopCart'),
        meta: {
            show: true
        }
    },
    {
        name: "addcartsuccess",
        path: '/addcartsuccess',
        component: () => import('@/pages/AddCartSuccess'),
        meta: {
            show: true
        }
    },
    {
        path: '/detail/:skuid',
        component: () => import('@/pages/Detail'),
        meta: {
            show: true
        }
    },
    {
        path: '/home',
        component: () => import('@/pages/Home'),
        meta: {
            show: true
        }
    },
    {
        name: "search",
        // 传参要有占位符
        path: '/search/:keyword?',
        component: () => import('@/pages/Search'),
        meta: {
            show: true
        },
        // props: true;
        props: ($route) => {
            return { k: $route.params.keyword }
        }
    },
    {
        path: '/login',
        component: () => import('@/pages/Login'),
        meta: {
            show: false
        }
    },
    {
        path: '/register',
        component: () => import('@/pages/Register'),
        meta: {
            show: false
        }
    },
    // 重定向,当项目启动时自动跳转到某组件
    {
        path: '/',
        redirect: "/home"
    }
]